﻿@{
    ViewBag.Title = "商品发货";
    Layout = "~/Views/Shared/_MallLayout.cshtml";
    var ExpressList = ViewBag.ExpressList as List<DropdownItem>;
    var order_id = ViewBag.order_id;
}
<body class="page-accound page-delivery">
    <div>
        <div class="accound">
            <ul>
                <li>
                    <span>交付方式</span>
                    <button class="way_btn  fn32" value="1" style="display:none">自提</button>
                    <button class="way_btn on fn32 " value="0" >邮寄</button>
                    <input type="hidden" id="ship_type" name="ship_type" value="0"/>
                </li>
                <li class="logist">
                    <span>物流公司</span>

                    <input class="in_put logistics_ipt fn32 express_company" type="text" id="picker" placeholder="请选择物流公司">
                    <i class="icon-btarrow"></i>
                    <input type="hidden" id="express_no" name="express_no"/>
                </li>
                <li class="logist">
                    <span>物流单号</span>
                    <input type="text" class="in_put fn32" placeholder="请输入物流单号" id="ship_num" />
                </li>
            </ul>
            <div class="confirm_btnry">
                <a class="ui-btn-buy shadow" id="btn_ship">确认发货</a>
            </div>
        </div>
    </div>
    <!-- 三级联动 -->
    <style type="text/css">
        .picker .picker-panel .wheel-wrapper .wheel {
            font-size: 16px
        }

        .picker .picker-panel .picker-choose .confirm {
            right: 10px;
            color: #ff504e;
        }
    </style>
    <script src="~/Scripts/tokenmall/lib/picker/picker.min.js"></script>

        <script type="text/javascript">
               var logistics = [
                @foreach(var item in ExpressList) {
                 <text>{ "name": "@item.Text","value":"@item.Value" },</text>
                }
                ]
        </script>
        <script src="~/Scripts/tokenmall/lib/picker/logisticsindex.js"></script>
    <script>
        $(function () {
            $(".accound li .way_btn").click(function () {
                $(this).addClass('on').siblings().removeClass('on');
                if ($(this).val() == 1) {
                    $(".accound .logist").hide();
                    $("#ship_type").val(1);
                }
                else { $(".accound .logist").show(); $("#ship_type").val(0);}
            });
            $("#btn_ship").click(function () {
                var ship_type = $("#ship_type").val();
                var express_no = $("#express_no").val();
                var express_company = $(".express_company").val();
                var ship_num = $("#ship_num").val();
                var id =@order_id;
                if (ship_type == 0) {
                    if (ship_num.length <= 0) { layer.msg("请填写物流单号"); return; }
                    if (express_no.length <= 0) { layer.msg("请选择物流公司"); return; }
                }
                var flag = false;
                  layer.confirm('您确定要发货么？', {
                 btn: ['确定', '取消'] //按钮
                     }, function () {
                           layer.load(1);
                           if (flag) return;
                           flag = true;
                 $.ajax({
                type: "POST",
                 dataType: "json",
                url: "/BazaarOrder/Ship",//url
                data: { id: id, ship_type: ship_type, express_no: express_no, express_company: express_company, ship_num: ship_num },
                success: function (result) {
                    layer.closeAll('loading');
                    if (result.result_code == 1000) {
                        layer.msg(result.result_msg);
                        location.href ='/BazaarOrder/SellOrder'
                    }
                    else {
                        layer.msg(result.result_msg);
                    }
                    flag = false;
                },
                error: function () {
                    layer.msg("异常！");
                    flag = false;
                }
            });
        }, function () {

        });
            });
        })
    </script>
</body>

